package org.resorator.dao.tx;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.restorator.dao.tx.C3PoDataSourceFactory;
import org.restorator.dao.tx.TransactionManager;
import org.restorator.dao.tx.TxManagerJdbc;
import org.restorator.exception.DataStoreException;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @author Snisar Bogdan.
 */
public class JdbcDataSourthProvider {

    static C3PoDataSourceFactory dd;

    @BeforeClass
    public static void setUp() throws IOException, PropertyVetoException {
//        dd = new DbcpDataSourceProvider(FileSearcher.getPathName("rdbc.propertie").getAbsolutePath());
          dd = new C3PoDataSourceFactory();
    }

    @Test
    public void testOpenDataSource() throws DataStoreException, SQLException {
        System.out.println(dd.getDataSourceProperties());
        Assert.assertFalse(dd.getDataSource().getConnection().isClosed());

    }

    @AfterClass
    public static void close() throws SQLException {
        dd.close();
    }
}
